package com.alibaba.citrus.cr.sales.plan.model.enums;

import lombok.Getter;

import java.util.Arrays;


/**
 * @author yuhailin
 * @description:月度计划状态
 * @date 2021-09-06 17:32
 */
@Getter
public enum SalesPlanStatusEnum {

    /**
     * 待锁定
     */
    TO_BE_LOCKED(0, "待锁定"),

    /**
     * 待同步
     * 对应业务单元审核通过，推进计划状态
     */
    TO_BE_SYNC(1, "待同步"),

    /**
     * 待回复
     */
    TO_BE_REPLIED(2, "待回复"),

    /**
     * 待发布
     */
    TO_BE_PUBLISHED(3, "待发布"),

    /**
     * 已发布
     */
    PUBLISHED(4, "已发布"),

    /**
     * 调整中
     */
    ADJUST(5,"调整中"),

    /**
     * 调整待回复
     */
    ADJUSTED_TO_BE_REPLIED(6,"调整待回复"),

    /**
     * 调整待发布
     */
    ADJUSTED_TO_BE_PUBLISHED(7,"调整待发布"),

    /**
     * 已取消
     */
    CANCEL(-1, "已取消");

    private Integer code;
    private String desc;

    SalesPlanStatusEnum(Integer code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public static String getDesc(Integer code) {
        for (SalesPlanStatusEnum salesplanStatusEnum : values()) {
            if(salesplanStatusEnum.getCode().equals(code)){
                return salesplanStatusEnum.getDesc();
            }
        }
        return null;
    }

    public static SalesPlanStatusEnum match(Integer code){
        if (code == null){
            return null;
        }
        return Arrays.stream(values()).filter(typeEnum -> typeEnum.getCode().equals(code)).findAny().orElse(null);
    }
}
